<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Repository\Product\GoodsRepository;
use App\Repository\UpThree\ThreeOrderRepository;
use App\Repository\UpThree\MainOrderRepostition;
use Illuminate\Support\Facades\DB;
use App\Repository\Product\SetAddressRepository;
use App\Repository\Product\ProductRepository;
use App\Repository\Api\GoodsRepository as apiGoods;
use App\Repository\Information\InformationRepository;
/**
 * @OA\Tag(
 *     name="后台菜单模块",
 *     description="菜单模块",
 * )
 */
class InformationController extends BaseController
{
  protected $InformationRepository;
  public function __construct()
  {
    $this->InformationRepository = new InformationRepository();
  }
  //发送验证码
  public function getSmsCode(Request $request){
    $data = $request->all();
    $res = $this->InformationRepository->queryMenu($data);
    dd($res);

    if($res['code'] != 200){
      return $this->returnMsg(-1, '获取套餐失败，请联系管理员');
    }
    //判断一下是否可以办理 整理出活动id
    //调用发短信接口
    $getCoderes = $this->InformationRepository->getSmsCode([
      'mobile' => $mobile,
      'offerId' => $res['offerId']
    ]);
    if($getCoderes['code'] != 200){
      return $this->returnMsg(-1, '发送验证码，请联系管理员');
    }
    return $res;
  }
  // 提交信息
  public function submitInfo(Request $request){
    //去验证验证码接口
    // $this->InformationRepository->
    $mobile = $request->get('mobile');//获取到手机号
    $code = $request->get('code');//获取到手机号
    $res = $this->InformationRepository->queryMenu([
      'code' =>$code,
      'mobile' => $mobile
    ]);
    if($res['code'] != 200){
      return $this->returnMsg(-1, '获取套餐失败，请联系管理员');
    }
    //存入数据库
    // $insertData = [];
    
    // $res = $this->model->insert($insertData);
    return $res;
  
  }

}
